﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrgPersTree.aspx.cs" Inherits="Common_OrgPersTree" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link type="text/css" rel="stylesheet" href ="../CSS/css.css" />
    <base target ="_self" />
    <script language="javascript" type="text/javascript">
    
    function OutPutDeptInfo(NodeCode)
       {
          eval("location.href = \"./ChoicePersTree.aspx?NodeCode="+NodeCode+"&OrgType="+ parent.form1.HOrgType.value + "&PageID="+ parent.form1.HPageID.value + "\";");
       }
       
    function ChoicePer(obj)
    {
//    var curID = objTreeCheckBox.value;
//    var selected = document.getElementById("Text1").value;
//    if(objTreeCheckBox.checked)
//        selected += curID + ",";
//    else
//        selected = selected.replace(","+curID+",",",");   
//    document.getElementById("Text1").value = selected;

       var sDelPersID   ="";  //人员ID 
        var sDelPersID2   ="";  //人员ID 
	    var sDelPersName = "";  //人员名称
	    var sDelPersName2 = "";  //人员名称
	    
        var aPers = obj.value.split(',');
        if(parent.form1.PersIDInfo.value != "")
        {
            var astr = parent.form1.PersIDInfo.value.split(',');
            if(astr.length=="1")
            {
                var sDelPersID   = aPers[0];  //人员ID 	        
	            var sDelPersName = aPers[1];  //人员名称
            }
            else
            {
                var sDelPersID   = "," + aPers[0];  //人员ID 	        
	            var sDelPersID2   = aPers[0] + ",";  //人员ID 
	            var sDelPersName = "," + aPers[1];  //人员名称
	            var sDelPersName2 = aPers[1] + ",";  //人员名称
	        }
	        
	        var sPersID   = "," + aPers[0];  //人员ID 
	        var sPersName = "," + aPers[1];  //人员名称
	        //var sPersIDInfo   = ","+ parent.form1.PersIDInfo.value;
            //var sPersNameInfo = ","+ parent.form1.PersNameInfo.value;
        }
        else
        {
            var sPersID   = aPers[0];  //人员ID 
	        var sPersName = aPers[1];  //人员名称
	        var sDelPersID   = aPers[0];  //人员ID 
	        var sDelPersName = aPers[1];  //人员名称
	        
	        //var sPersIDInfo   = parent.form1.PersIDInfo.value;
            //var sPersNameInfo = parent.form1.PersNameInfo.value;
        }
        //debugger;
        if(obj.checked)
        {
           parent.form1.PersIDInfo.value = parent.form1.PersIDInfo.value.replace(sDelPersID,"");
           parent.form1.PersIDInfo.value = parent.form1.PersIDInfo.value.replace(sDelPersID2,"");
           parent.form1.PersIDInfo.value = parent.form1.PersIDInfo.value + sPersID ;
           parent.form1.PersNameInfo.value = parent.form1.PersNameInfo.value.replace(sDelPersName,"");
           parent.form1.PersNameInfo.value = parent.form1.PersNameInfo.value.replace(sDelPersName2,"");
           parent.form1.PersNameInfo.value = parent.form1.PersNameInfo.value + sPersName ;
        }
        else
        {
            parent.form1.PersIDInfo.value   = parent.form1.PersIDInfo.value.replace(sDelPersID,"");
            parent.form1.PersIDInfo.value   = parent.form1.PersIDInfo.value.replace(sDelPersID2,"");
            parent.form1.PersNameInfo.value = parent.form1.PersNameInfo.value.replace(sDelPersName,"");
            parent.form1.PersNameInfo.value = parent.form1.PersNameInfo.value.replace(sDelPersName2,"");
        }
        //alert(form1.PersIDInfo.value);
        //alert(form1.PersNameInfo.value);
    }


    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type="hidden" id="HOrgType" runat ="server"  />
<input type="hidden" id="HPageID" runat ="server"  />
<input type="hidden" id="OrgIDInfo" runat ="server"  />
<input type="hidden" id="OrgNameInfo" runat ="server"  />
<input type="hidden" id="PersIDInfo" runat ="server"  /> 
<input type="hidden" id="PersNameInfo" runat ="server"  /> 
<input type="hidden" id="POPIDCol" runat ="server"  /> 
<input type="hidden" id="POPNameCol" runat ="server"  /> 

<input type="hidden" id="PersCount" runat ="server"  /> 
<input type="hidden" id="OrgCount" runat ="server"  /> 
      <asp:TreeView ID="tvOrgTree" runat="server"
            Target="frmMain" OnSelectedNodeChanged="tvOrgTree_SelectedNodeChanged"  OnTreeNodeExpanded="tvOrgTree_TreeNodeExpanded"
             ShowLines="True" OnTreeNodeCollapsed="tvOrgTree_TreeNodeCollapsed" NodeWrap="True" >
        </asp:TreeView>      
    </div>
    </form>
    
    <script language ="javascript" type ="text/javascript" >
        parent.form1.PersIDInfo.value =  parent.form1.POPIDCol.value ;  //人员ID初始化
        parent.form1.PersNameInfo.value =  parent.form1.POPNameCol.value ;  //人员Name初始化
        //debugger;
        var iPersNum = form1.PersCount.value*1;
        var iOrgNum = form1.OrgCount.value*1;
        //人员ID的赋值
        for(i=0;i<iPersNum;i++)
        {
            if(iPersNum=="1")
            {
                var PersValue = document.all.PersCK.value;
                var PersAry = PersValue.split('^');
                
                var aPersID = parent.form1.POPIDCol.value.split(',');
                var iPersID = aPersID.length;
                for(k=0;k<iPersID;k++)
                {
                    if(aPersID[k]==PersAry[0])
                    {
                       document.all.PersCK.checked = true;
                       break;
                    }
                }
            }
            else
            {
                var PersValue = document.all.PersCK[i].value;
                var PersAry = PersValue.split('^');
                
                var aPersID = parent.form1.POPIDCol.value.split(',');
                var iPersID = aPersID.length;
                for(k=0;k<iPersID;k++)
                {
                    if(aPersID[k]==PersAry[0])
                    {
                       document.all.PersCK[i].checked = true;
                       break;
                    }
                }
            }
        }
     </script>
</body>
</html>
